﻿#define LOGIN_USE_NORMAL

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

/// <summary>
/// 登录模块
/// </summary>
public class Logon : BaseController {

    /// <summary>
    /// 通用用户名输入框
    /// </summary>
    public InputField normalInput;

    ///////////////////////////////////////////////////////////////////////////

    protected override void InitView()
    {
        base.InitView();

#if LOGIN_USE_NORMAL
        normalInput.gameObject.SetActive(true);
        Debug.Log("使用普通方式登录");
#else
        Debug.Log("使用微信登录");
#endif
    }

    ///////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// 登录按钮被点击
    /// </summary>
    public void OnLoginBtnClick()
    {
        Debug.Log("登录按钮被点击");

#if LOGIN_USE_NORMAL
        LoginReqInfo reqInfo = new LoginReqInfo();
        reqInfo.openid = normalInput.text;
        reqInfo.name = normalInput.text;
        reqInfo.headpic = "";
        reqInfo.sex = 0;
        DoLogin(reqInfo);
#else
        // TODO
#endif
    }

    /// <summary>
    /// 处理登录请求
    /// </summary>
    /// <param name="reqInfo">登录参数</param>
    void DoLogin(LoginReqInfo reqInfo)
    {
        Debug.Log("登录中:" + reqInfo.ToString());

        // TODO 处理登录
    }
}
